package com.cj;

import com.cj.consumer.RoleService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author cc
 * @date 2025-05-13 14:17
 **/

public class Demo01 {
    public static void main(String[] args) {
        // 创建容器，，不要初始化容器，，容器真正初始化是refresh方法
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext();
//        ClassPathXmlApplicationContext merchantCtx = new ClassPathXmlApplicationContext("beans-merchant.xml");


        // 后面的配置文件，，把前面的覆盖了
        ctx.setConfigLocations("beans-consumer.xml","beans-merchant.xml");

        // 是否允许bean定义的覆盖，，， 默认为true，设置为false，，如果出现了同名的bean，，直接报错
        ctx.setAllowBeanDefinitionOverriding(false);

        ctx.refresh();


        RoleService roleService = ctx.getBean(com.cj.consumer.RoleService.class);

//        com.cj.merchant.RoleService bean = ctx.getBean(com.cj.merchant.RoleService.class);
////        System.out.println("roleService = " + roleService);
//        System.out.println("bean = " + bean);

    }
}
